package com.lmt_15;

import java.io.BufferedWriter;
import java.io.FileWriter;

public class XMLWriteTest {
    public static void main(String[] args) {
         StringBuilder builder = new StringBuilder();
         builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n");
         builder.append("<book>\r\n");
         builder.append("\t<name>").append("从入门到精通").append("</name>\r\n");
         builder.append("\t<author>").append("heima").append("</author>\r\n");
        builder.append("\t<price>").append(50.2).append("</price>\r\n");
        builder.append("</book>");

       try(
               BufferedWriter writer = new BufferedWriter(new FileWriter("src/com/lmt_15/text.xml"));
               ){
           writer.write(builder.toString());
       }catch (Exception e){
           e.printStackTrace();
       }
    }
}
